//
//  JiaoChengController.swift
//  JianTingSwift
//
//  Created by zhibao on 2024/11/9.
//

import UIKit

class JiaoChengController: SecSuperController {

    //1去电  2来电
    var type:Int = 1
    var contents = [[String:String]]()
    var scrollview = UIScrollView(frame: CGRectMake(0, navigationFullHeight(), SCREEN_WIDTH, SCREEN_HEIGHT - navigationFullHeight()))
    override func viewDidLoad() {
        super.viewDidLoad()
        
        if type == 1 {
            self.gk_navTitle = LocalizedString("去电教程")
            contents = [
                [
                    "title":LocalizedString("1.点击【点击录音】按钮获取录音号码"),
                    "img":LocalizedString("1.jpg")
                ],[
                    "title":LocalizedString("2.点击【呼叫(号码)】按钮"),
                    "img":LocalizedString("2.jpg")
                ],[
                    "title":LocalizedString("3.接通后，点击【添加】按钮，随后拨通所要呼叫的联系人"),
                    "img":LocalizedString("3.jpg")
                ],[
                    "title":LocalizedString("4.接通后，点击【合并通话】按钮，即可开始通话录音"),
                    "img":LocalizedString("4.jpg")
                ],
            ]
        }else{
            self.gk_navTitle = LocalizedString("来电教程")
            contents = [
                [
                    "title":LocalizedString("1.先接通电话，然后打开APP，点击【电话监听】获取录音号码"),
                    "img":LocalizedString("1.jpg")
                ],[
                    "title":LocalizedString("2.点击【呼叫】按钮"),
                    "img":LocalizedString("2.jpg")
                ],[
                    "title":LocalizedString("3.接通后，点击【合并通话】按钮，即可开始通话录音"),
                    "img":LocalizedString("4.jpg")
                ],
            ]
        }
        
        
        self.view.addSubview(scrollview)
        var tempView:UIView?
        for i in 0 ..< contents.count {
            let tempContent = contents[i]
            let titleLabel = UILabel()
            titleLabel.text = tempContent["title"]
            titleLabel.textColor = UIColor.white
            titleLabel.numberOfLines = 0
            titleLabel.lineBreakMode = .byWordWrapping
            titleLabel.font = MY_SCALE_MediumFONT(17)
            scrollview.addSubview(titleLabel)
            titleLabel.snp.makeConstraints { make in
                make.left.equalTo(20)
                make.right.equalTo(self.view).offset(-20)
                if i == 0 {
                    make.top.equalTo(40)
                }else{
                    make.top.equalTo(tempView!.snp.bottom).offset(30)
                }
            }
            
            let img = UIImage(named: tempContent["img"] ?? "")
            let imgHeight = (img?.size.height ?? 1) * pixw(p: 300) / (img?.size.width ?? 1)
            let imgView = UIImageView(image: UIImage(named: tempContent["img"] ?? ""))
            scrollview.addSubview(imgView)
            imgView.snp.makeConstraints { make in
                make.centerX.equalTo(titleLabel)
                make.top.equalTo(titleLabel.snp.bottom).offset(6)
                make.width.equalTo(pixw(p: 300))
                make.height.equalTo(imgHeight)
                if i == contents.count - 1 {
                    make.bottom.equalTo(scrollview).offset(-30)
                }
            }
            tempView = imgView
        }
    }
}
